package com.duzilin.ehrecyclerview.demo;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.duzilin.ehrecyclerview.R;
import com.duzilin.ehrecyclerview.Wrapper.RecyclerViewAdapterPlus;

/**
 * Created by DuZiLin on 2018/1/5.
 */

public class MyAdapter extends RecyclerViewAdapterPlus<String> {
    @Override
    public RecyclerView.ViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_item, parent , false);
        return new TvViewHolser(itemView);
    }

    @Override
    public void onBindItemViewHolder(RecyclerView.ViewHolder viewHolder, int position, String data) {
       TvViewHolser tvHolder = (TvViewHolser)viewHolder;
       tvHolder.tv.setText(data);
    }

    class TvViewHolser extends RecyclerView.ViewHolder{
        TextView tv;
        public TvViewHolser(View itemView) {
            super(itemView);
            tv = itemView.findViewById(R.id.item_tv);
        }
    }


}
